//
//  FirstViewController.m
//  07-delegate和block
//
//  Created by dllo on 16/7/22.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "FirstViewController.h"
#import "SecondViewController.h"

@interface FirstViewController ()<SecondVCPassValue>
@property (nonatomic,strong) UILabel *titleLabel;
@end

@implementation FirstViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(100, 100, 100, 40);
    button.backgroundColor = [UIColor redColor];
    [button addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 100, 30)];
    titleLabel.backgroundColor = [UIColor redColor];
    titleLabel.text = @"海贼王";
    titleLabel.alpha = 0.2;
    titleLabel.textColor = [UIColor whiteColor];
    [self.view addSubview:titleLabel];
    
    
//    关于basecontroller是基类的viewcontroller在这个controller中，进行统一的修改，修改坐标系和北京颜色，navigationbar的bartintcolor tintcolor等
    
    
}


- (void)viewWillAppear:(BOOL)animated

{
    [super viewWillAppear:animated];
    
}

- (void)buttonClicked
{
    SecondViewController *svc = [[SecondViewController alloc] init];
//    svc.titleString = self.titleLabel.text;
    svc.delegate = self;
    
    
    
    [self.navigationController pushViewController:svc animated:YES];
}

//实现协议方法
- (void)passValue:(NSString *)string
{
    NSLog(@"%@",string);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
